home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / GAS211S2.ZIP / src / gas-211 / include / elf / internal.h < prev   
Text File  |  1993-05-30  |  5KB  |  136 lines

  1. /* ELF support for BFD.
  2.    Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  3.  
  4.    Written by Fred Fish @ Cygnus Support, from information published
  5.    in "UNIX System V Release 4, Programmers Guide: ANSI C and
  6.    Programming Support Tools".
  7.  
  8. This file is part of BFD, the Binary File Descriptor library.
  9.  
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2 of the License, or
  13. (at your option) any later version.
  14.  
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. GNU General Public License for more details.
  19.  
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software
  22. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  23.  
  24.  
  25. /* This file is part of ELF support for BFD, and contains the portions
  26.    that describe how ELF is represented internally in the BFD library.
  27.    I.E. it describes the in-memory representation of ELF.  It requires
  28.    the elf-common.h file which contains the portions that are common to
  29.    both the internal and external representations. */
  30.    
  31. /* Types used by various structures, functions, etc. */
  32.  
  33. typedef unsigned long    Elf_Addr;    /* Unsigned program address */
  34. typedef unsigned long    Elf_Off;    /* Unsigned file offset */
  35. typedef      long    Elf_Sword;    /* Signed large integer */
  36. typedef unsigned long    Elf_Word;    /* Unsigned large integer */
  37. typedef unsigned short    Elf_Half;    /* Unsigned medium integer */
  38. typedef unsigned char    Elf_Char;    /* Unsigned tiny integer */
  39.  
  40. /* ELF Header */
  41.  
  42. #define EI_NIDENT    16        /* Size of e_ident[] */
  43.  
  44. typedef struct elf_internal_ehdr {
  45.   unsigned char    e_ident[EI_NIDENT];    /* ELF "magic number" */
  46.   Elf_Half    e_type;            /* Identifies object file type */
  47.   Elf_Half    e_machine;        /* Specifies required architecture */
  48.   Elf_Word    e_version;        /* Identifies object file version */
  49.   Elf_Addr    e_entry;        /* Entry point virtual address */
  50.   Elf_Off    e_phoff;        /* Program header table file offset */
  51.   Elf_Off    e_shoff;        /* Section header table file offset */
  52.   Elf_Word    e_flags;        /* Processor-specific flags */
  53.   Elf_Half    e_ehsize;        /* ELF header size in bytes */
  54.   Elf_Half    e_phentsize;        /* Program header table entry size */
  55.   Elf_Half    e_phnum;        /* Program header table entry count */
  56.   Elf_Half    e_shentsize;        /* Section header table entry size */
  57.   Elf_Half    e_shnum;        /* Section header table entry count */
  58.   Elf_Half    e_shstrndx;        /* Section header string table index */
  59. } Elf_Internal_Ehdr;
  60.  
  61. /* Program header */
  62.  
  63. typedef struct elf_internal_phdr {
  64.   Elf_Word    p_type;            /* Identifies program segment type */
  65.   Elf_Off    p_offset;        /* Segment file offset */
  66.   Elf_Addr    p_vaddr;        /* Segment virtual address */
  67.   Elf_Addr    p_paddr;        /* Segment physical address */
  68.   Elf_Word    p_filesz;        /* Segment size in file */
  69.   Elf_Word    p_memsz;        /* Segment size in memory */
  70.   Elf_Word    p_flags;        /* Segment flags */
  71.   Elf_Word    p_align;        /* Segment alignment, file & memory */
  72. } Elf_Internal_Phdr;
  73.  
  74. /* Section header */
  75.  
  76. typedef struct elf_internal_shdr {
  77.   Elf_Word    sh_name;        /* Section name, index in string tbl */
  78.   Elf_Word    sh_type;        /* Type of section */
  79.   Elf_Word    sh_flags;        /* Miscellaneous section attributes */
  80.   Elf_Addr    sh_addr;        /* Section virtual addr at execution */
  81.   Elf_Off    sh_offset;        /* Section file offset */
  82.   Elf_Word    sh_size;        /* Size of section in bytes */
  83.   Elf_Word    sh_link;        /* Index of another section */
  84.   Elf_Word    sh_info;        /* Additional section information */
  85.   Elf_Word    sh_addralign;        /* Section alignment */
  86.   Elf_Word    sh_entsize;        /* Entry size if section holds table */
  87.  
  88.   /* The internal rep also has some cached info associated with it. */
  89.   void        *rawdata;        /* null if unused... */
  90.   void        *contents;        /* null if unused... */
  91.   unsigned    size;            /* size of contents (0 if unused) */
  92. } Elf_Internal_Shdr;
  93.  
  94. /* Symbol table entry */
  95.  
  96. typedef struct elf_internal_sym {
  97.   Elf_Word    st_name;        /* Symbol name, index in string tbl */
  98.   Elf_Addr    st_value;        /* Value of the symbol */
  99.   Elf_Word    st_size;        /* Associated symbol size */
  100.   Elf_Char    st_info;        /* Type and binding attributes */
  101.   Elf_Char    st_other;        /* No defined meaning, 0 */
  102.   Elf_Half    st_shndx;        /* Associated section index */
  103. } Elf_Internal_Sym;
  104.  
  105. /* Note segments */
  106.  
  107. typedef struct elf_internal_note {
  108.   Elf_Word    namesz;            /* Size of entry's owner string */
  109.   Elf_Word    descsz;            /* Size of the note descriptor */
  110.   Elf_Word    type;            /* Interpretation of the descriptor */
  111.   char        name[1];        /* Start of the name+desc data */
  112. } Elf_Internal_Note;
  113.  
  114. /* Relocation Entries */
  115.  
  116. typedef struct elf_internal_rel {
  117.   Elf_Addr    r_offset;    /* Location at which to apply the action */
  118.   Elf_Word    r_info;        /* index and type of relocation */
  119. } Elf_Internal_Rel;
  120.  
  121. typedef struct elf_internal_rela {
  122.   Elf_Addr    r_offset;    /* Location at which to apply the action */
  123.   Elf_Word    r_info;        /* Index and Type of relocation */
  124.   Elf_Sword    r_addend;    /* Constant addend used to compute value */
  125. } Elf_Internal_Rela;
  126.  
  127. /* dynamic section structure */
  128.  
  129. typedef struct {
  130.   Elf_Sword d_tag;        /* entry tag value */
  131.   union {
  132.     Elf_Word    d_val;
  133.     Elf_Addr    d_ptr;
  134.   } d_un;
  135. } Elf_Internal_Dyn;
  136.